package com.party.core.model.commune;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 积分类型枚举
 * Created by hqh.
 *
 * @date 2019/11/25 0023
 * @time 11:35
 */
public enum IntegralType {

    CINTEGRALTYPE_CATEGORY_ORDINARY(0, "普通类型"),
    CINTEGRALTYPE_CATEGORY_RECOMMEND(1, "推荐类型"),
    CINTEGRALTYPE_CATEGORY_GIFT(2, "赠送类型");

    //状态码
    private Integer code;

    //状态值
    private String value;

    IntegralType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValue(Integer code){
        for (IntegralType integralType : IntegralType.values()){
            if (integralType.getCode().equals(code)){
                return integralType.getValue();
            }
        }
        return null;
    }

    public static Map<Integer, String> convertMap(){
        Map<Integer, String> map = Maps.newHashMap();
        for (IntegralType integralType : IntegralType.values()){
            map.put(integralType.getCode(), integralType.getValue());
        }
        return map;
    }

}
